Repository navigation
JSE-21: unmapped schema fields are null in every row - #100
Merged
Merged
Conversation
applyMapping (and so importDataset) now gives every schema field a column and a key in every row: a field without a column is null, with an entry in columns (title and letter '', type 'empty', its field). Rows always have the schema's shape, so validators such as Zod's .nullable() accept them; before, the key was missing. A required field without a column still gives one MAPPING_MISSING issue and no per-row REQUIRED issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JSE-21: unmapped schema fields come back as
null, so imported rows always have the schema's shape. Afzal approved it (proposed in react-data-import #10). It's a behaviour change in the prerelease, with a minor changeset.Change
applyMapping, and soimportDatasetwith aschema:null. Before, the key was missing, so a Zod.nullable()field failed with "expected date, received undefined".columnshas one entry per schema field. An unmapped field's entry hastitle: '',letter: '',type: 'empty'and itsfield, so columns and rows match.MAPPING_MISSINGissue (row 0). It'snullin the rows, and gets no per-rowREQUIREDissue (that was already the case).meta.mapping(unmapped fields arenullthere),meta.unmappedColumns,unmapped: 'keep'(a kept column whose key equals a field name is still suffixed_2).Flag: the brief covered the rows. I made
columnslist every schema field as well, so that a consumer iteratingcolumns, react-data-export'sexportDataset(result)for example, sees the same shape as the rows. react-data-import'suseColumnMappingalready skips fields whose mapping isnull, so it's unaffected.Docs and tests
docs/api.md§5.6: theImportDatasetResult.columnscomment and theapplyMappingbullets.test/import/mapping.test.ts: the two expectations that encoded the old shape now expect null-valued keys and full schema columns.test/import/pipeline.test.ts: a new "unmapped schema fields (JSE-21)" block:emptycolumns andmeta.mappingnullMAPPING_MISSING, nulls, and noREQUIREDFollow-up
react-data-import picks this up once it ships in the next javascript-excel alpha. That PR covers its docs and types (§4.2/§6: "one per schema field"), and switches the playground's demo schema back from
.nullish()to.nullable().